use ini::Ini;

const APP_CONFIG_SECTION: &'static str = "AppConfig";

#[derive(Debug,Default)]
pub struct AppConfig{
    pub name:String,
    pub datasource: String
}

impl AppConfig {
    
    pub fn new(cfg_path: &'static str) -> AppConfig {
        let ini_obj=Ini::load_from_file(cfg_path).unwrap();
        let app_name = ini_obj.get_from(Some(APP_CONFIG_SECTION), "name").unwrap();
        let app_datasource = ini_obj.get_from(Some(APP_CONFIG_SECTION), "datasource").unwrap();
        AppConfig{
            name: app_name.to_string(),
            datasource: app_datasource.to_string()
        }
    }
}